package Twice.day06;

/**
 * @Author: lya
 * @Description: 本类的作用描述:
 * @CreateDate: 2019/8/31
 * @Version: 1.0
 */
public class Test {
    public static void main(String[] args) {

        //强制转换看运行时类型!
        //instanceof判断为true都能转
        A a1 = new A();
        B b1 = new B();
        A a2 = new B();
        //B b2 = (B) new A();//不能转

        A a4 = b1;
        System.out.println(a4 instanceof A);//true
        System.out.println(a4 instanceof B);//true
        System.out.println("===================");

        A a5 = a2;
        System.out.println(a5 instanceof A);//true
        System.out.println(a5 instanceof B);//true
        System.out.println("===================");


//        B b3 = (B) a1;//不能转
        B b5 = (B) a2;
        System.out.println(b5 instanceof A);//true
        System.out.println(b5 instanceof B);//true






    }
}
